<template>
  <!-- 主页头部导航栏 -->
  <div class="topNavbar">
    <div class="logo" @click="backToHome">
      <img src="../assets/images/logo2.png">
    </div>
    <div class="searchBox" @click="toSearch">
      <div class="searchBar">
        <img src="../assets/images/search.png" class="search_icon">
        <span class="search_text">搜索</span>
      </div>
    </div>
    <div class="btn_box" @click="toLogin">
      登录
    </div>
  </div>
  <!-- 搜索框 -->
</template>
  
<script setup lang="ts">
import { useRouter } from "vue-router"
const router = useRouter()

/* 点击logo图片的回调 */
const backToHome = () => {
  router.push({
    path: "/home"
  })
}

/* 点击搜索框的回调 */
const toSearch = () => {
  router.push({
    path: "/search"
  })
}

/* 点击登录的回调 */
const toLogin = () => {
  router.push({
    path: "/login"
  })
}
</script>
  
<style lang="less" scoped>
.topNavbar {
  width: 375px;
  height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 15px 5px;
  box-sizing: border-box;
}

.logo {
  width: 70px;
  height: 15px;
  position: relative;

  img {
    width: 100%;
    height: 100%;
    position: absolute;
  }
}

.btn_box {
  width: 68px;
  height: 30px;
  background-color: #FA2800;
  border-radius: 15px;
  color: #fff;
  font-size: 12px;
  text-align: center;
  line-height: 30px;
}

.searchBox {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 182px;
  height: 30px;
}

.searchBar {
  display: flex;

  align-items: center;
  width: 345.2px;
  height: 30px;
  background-color: rgb(239, 241, 244);
  border-radius: 20px;
}

.search_icon {
  width: 14px;
  height: 14px;
  margin-left: 10px;
}

.search_text {
  font-size: 12px;
  color: #ABABAB;
  margin-left: 10px;
}
</style>